package com.example.stock.service.stat;

import com.example.stock.compone.EmaComponent;
import com.example.stock.service.StockStatService;
import com.example.stock.vo.DataVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;

/**
 * @Author: zhuchunfeng
 * @Description
 * @Date: 2021/1/3 15:39
 * Copyright (c) 2019 北京新媒传信科技有限公司
 */
@Service
public class StatService {

    @Resource
    private StockStatService stockStatService;
    @Resource
    private EmaComponent emaComponent;

    public void statisticsMa(List<DataVo> closeData) {
        for (int i = 1; i < 400; i++) {
            int n = i * 24;
            BigDecimal finalMoney = stockStatService.analysisMaUpDown(n, closeData);
            emaComponent.recordTen(0, n, finalMoney,null);
        }
    }

    public void statisticsMaCross(List<DataVo> closeData) {
        for (int i = 1; i < 100; i++) {
            for (int j = i+1; j < 100; j++) {
                int m = j * 24;
                int n = i * 24;
                BigDecimal finalMoney = stockStatService.analysisMaCross(m, n, closeData);
                emaComponent.recordTen(m, n, finalMoney,null);
            }
        }
    }

    public void statisticsEma(List<DataVo> closeData) {
        for (int i = 1; i < 25; i++) {
            for (int j = 1; j < 25; j++) {
                int m = j * 48;
                int n = i * 48;
                BigDecimal finalMoney = stockStatService.analysisEmaUpDown(m, n, closeData,false);
                emaComponent.recordTen(m, n, finalMoney,null);
            }
        }
    }

    public void statisticsEma30(List<DataVo> closeData) {
        for (int i = 1; i < 100; i++) {
            for (int j = 1; j < 100; j++) {
                int m = j * 1;
                int n = i * 1;
                BigDecimal finalMoney = stockStatService.analysisEmaUpDown(m, n, closeData,false);
                emaComponent.recordAll(m, n, finalMoney,null);
                System.out.println("m: " + m + "n: " + n);
            }
        }
        emaComponent.finishRecordAll();
    }

    public void statisticsEmaAdjust(int m, int n, List<DataVo> closeData) {
        for (BigDecimal refer = new BigDecimal("0.1");
             refer.compareTo(new BigDecimal("20")) < 0;
             refer = refer.add(new BigDecimal("0.1"))) {
            BigDecimal finalMoney = stockStatService.analysisEmaAdjust(m, n, closeData, refer);
            emaComponent.recordTen(m, n, finalMoney,refer);
        }

    }



}
